<template>
  <!-- 人气推荐模块 -->
  <HomePanel ref="target" title="人气推荐" subTitle="人气爆款不容错过">
    <template #>
      <ul ref="pannel" class="goods-list">
        <li v-for=" item in list" :key="item.id">
          <RouterLink to="/">
            <img :src="item.picture" alt="" />
            <p class="name">{{item.name}}</p>
            <p>{{item.title}}</p>
            <p class="desc">{{item.alt}}</p>
          </RouterLink>
        </li>
      </ul>
    </template>
  </HomePanel>
</template>

<script>
import HomePanel from './home-panel'
import { findHot } from '@/api/home'
import { ref } from 'vue'
import { useObserver } from '@/compositions'
export default {
  components: {
    HomePanel
  },
  setup () {
    const list = ref([])
    async function findHotFn () {
      const res = await findHot()
      console.log('人气推荐有', res.data.result)
      list.value = res.data.result
    }
    const { target } = useObserver(findHotFn)
    return {
      list,
      target
    }
  }
}
</script>

<style scoped lang='less'>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    .price {
      color: @priceColor;
    }
      .desc {
      color: #999;
      font-size: 18px;
    }
  }
}
</style>
